const express = require('express');
const router = express.Router();
const multer = require('multer');
const booksController = require('../controller/booksController');

// 创建文件路径
const upload = multer({ dest: './upload' });

// 查找
router.get('/getbook', booksController.findAll);

// 获取单条数据
router.get('/getOnebook/:id', booksController.findOne);

// 添加
router.post('/addbook', upload.single('cover'), booksController.addBook);

// 编辑
router.put('/putbook', upload.single('cover'), booksController.editBook);

//删除
router.delete('/deletebook', booksController.delete);

module.exports = router;
